<?php

// +----------------------------------------------------------------------
// | H1CMS © OpenSource CMS
// +----------------------------------------------------------------------
// | Copyright (c) 2014-2016 http://www.h1cms.com All rights reserved.
// | Copyright (c) 2014-2016 嘉兴领格信息技术有限公司，并保留所有权利。
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: Allen <allen@lg4.cn>
// +----------------------------------------------------------------------

namespace Lg\Validation;

use Lg\Http\Input;

/**
 * Description of Validator
 *
 * @author Allen <allen@lg4.cn>
 */
class Validator {

    public $data;

    public function __construct($input = null) {
        if (is_null($input)) {
            $this->data = Input::all();
        }
    }

    /**
     * 
     * @param type $data
     * @param type $fields
     * @param type $lang
     * @param type $langDir
     * @return \Valitron\Validator
     */
    public static function make($data, $fields = array(), $lang = 'zh_cn', $langDir = null) {
        $validator = new \Valitron\Validator($data, $fields, $lang, $langDir);
        return $validator;
    }

    public static function passes() {
        $v = new static;
        $validator = new \Valitron\Validator($v->data);
        $validator->rules($v->rules());
        return $validator->validate();
    }

    public static function fails() {
        $v = new static;
        $validator = new \Valitron\Validator($v->data);
        $validator->rules($v->rules());
        return !$validator->validate();
    }

    public function rules() {
        return [];
    }

    public function attributes() {
        return [];
    }

}
